import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => { require(['@/views/login.vue'], resolve); }
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => { require(['@/views/error-page/404.vue'], resolve); }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: resolve => { require(['@//views/error-page/403.vue'], resolve); }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: resolve => { require(['@/views/error-page/500.vue'], resolve); }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: resolve => { require(['@/views/home/home.vue'], resolve); } },
        { path: '/product/edit', title: '商品编辑', name: 'product_edit', component: resolve => { require(['@/views/product/edit.vue'], resolve); } }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/dashboard',
        icon: 'home',
        title: '首页',
        name: 'dashboard',
        component: Main,
        children: [
            { path: 'index', title: 'Page', name: 'page_index', component: resolve => { require(['@/views/home/home.vue'], resolve); } }
        ]
    },
    {
        path: '/user',
        icon: 'android-person',
        name: 'user',
        title: '会员管理',
        component: Main,
        children: [
            {
                path: '/user/list',
                icon: 'ios-paper-outline',
                name: 'user',
                title: '会员列表',
                component: resolve => { require(['@/views/user/list.vue'], resolve); }
            }
        ]
    },
    {
        path: '/order',
        icon: 'ios-paper',
        name: 'order',
        title: '挂单管理',
        component: Main,
        children: [
            {
                path: '/order/coin',
                icon: 'ios-paper-outline',
                name: 'coin',
                title: '构树链',
                component: resolve => { require(['@/views/order/coin.vue'], resolve); }
            },
            {
                path: '/order/sapling',
                icon: 'leaf',
                name: 'sapling',
                title: '构树苗',
                component: resolve => { require(['@/views/order/sapling.vue'], resolve); }
            }
        ]
    },
    {
        path: '/config',
        icon: 'gear-b',
        name: 'operation',
        title: '系统配置',
        component: Main,
        children: [
            {
                path: '/sys/setting',
                icon: 'ios-pulse-strong',
                name: 'sysconfig',
                title: '运营配置',
                component: resolve => { require(['@/views/setting/sys.vue'], resolve); }
            },
            {
                path: '/sys/csetting',
                icon: 'arrow-graph-up-left',
                name: 'csysconfig',
                title: '运营参数',
                component: resolve => { require(['@/views/setting/csys.vue'], resolve); }
            },
            {
                path: '/sysstatic/setting',
                icon: 'fireball',
                name: 'staticconfig',
                title: '算力比例',
                component: resolve => { require(['@/views/setting/autoup.vue'], resolve); }
            }
        ]
    },
    {
        path: '/config',
        icon: 'ios-partlysunny',
        name: 'config',
        title: '运营管理',
        component: Main,
        children: [
            {
                path: '/sms/setting',
                icon: 'ios-paper-outline',
                name: 'smsconfig',
                title: '短信配置',
                component: resolve => { require(['@/views/setting/sms.vue'], resolve); }
            },
            {
                path: '/sys/notice',
                icon: 'android-textsms',
                name: 'notice',
                title: '系统公告',
                component: resolve => { require(['@/views/setting/notice.vue'], resolve); }
            },
            {
                path: '/sys/holiday',
                icon: 'ios-calculator',
                name: 'holiday',
                title: '节假日管理',
                component: resolve => { require(['@/views/setting/holiday.vue'], resolve); }
            }
        ]
    },
    {
        path: '/product',
        icon: 'cube',
        name: 'product',
        title: '商品管理',
        component: Main,
        children: [
            {
                path: '/product/list',
                icon: 'ios-paper-outline',
                name: 'product',
                title: '商品列表',
                component: resolve => { require(['@/views/product/list.vue'], resolve); }
            },
            {
                path: '/product/cate',
                icon: 'ios-copy-outline',
                name: 'cate',
                title: '商品分类',
                component: resolve => { require(['@/views/product/catelist.vue'], resolve); }
            },
            {
                path: '/product/orderpro',
                icon: 'social-twitch-outline',
                name: 'orderpro',
                title: '商品订单',
                component: resolve => { require(['@/views/product/orderpro.vue'], resolve); }
            }
        ]
    },
    {
        path: '/log',
        icon: 'record',
        name: 'log',
        title: '系统日志',
        component: Main,
        children: [
            {
                path: '/coin/log',
                icon: 'social-bitcoin-outline',
                name: 'coinlog',
                title: '构树链记录',
                component: resolve => { require(['@/views/record/coin.vue'], resolve); }
            },
            {
                path: '/sapling/log',
                icon: 'leaf',
                name: 'saplinglog',
                title: '构树苗记录',
                component: resolve => { require(['@/views/record/sapling.vue'], resolve); }
            },
            {
                path: '/point/log',
                icon: 'pinpoint',
                name: 'pointlog',
                title: '积分记录',
                component: resolve => { require(['@/views/record/point.vue'], resolve); }
            },
            {
                path: '/sms/log',
                icon: 'android-textsms',
                name: 'smslog',
                title: '短信记录',
                component: resolve => { require(['@/views/record/sms.vue'], resolve); }
            }
        ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    ...appRouter,
    page500,
    page403,
    page404
];
